import React, { useEffect, useState } from 'react';

export default function App() {
  const [count, setCount] = useState(99);
  const [msg, setMsg] = useState('hello React');

  useEffect(() => {
    console.log('我被触发了  ----->  ');
    // useEffect同时监听多个变量的变化
  }, [count, msg]);

  return (
    <div>
      App
      <h1>{count}</h1>
      <h1>{msg}</h1>
      <hr />
      <button onClick={() => setCount(count + 1)}>count+1</button>
      <button onClick={() => setMsg(msg + '~')}>msg+"~~"</button>
    </div>
  );
}
